package presentation;

import common.Application;
import formatters.*;
import parsers.InputParser;
import runtime.RuntimeInstance;
import templates.PresentationTemplate;
import templates.PropertyTemplate;

public abstract class PresentationElement implements RuntimeInstance {
    protected short uid;
    protected String value;

    protected PresentationElement() {
        uid = 0;
        value = "";
    }

    public abstract void acceptView(ViewFormatter f);
    public abstract void acceptEdit(EditFormatter f);
    public abstract void acceptInput(InputParser p);

    public String getValue() {
        return value;
    }

    public void setValue(String value) {
        this.value = value;
    }

    public short getUid() {
        return uid;
    }

    public void setUid(short uid) {
        this.uid = uid;
    }

    public PresentationTemplate getTemplate() {
        return Application.getInstance().getTemplate((short) (uid & 0xFF00)).getPresentationTemplate(uid);
    }

    public PropertyTemplate getPropertyTemplate() {
        return Application.getInstance().getTemplate((short) (uid & 0xFF00)).getPropertyTemplate(getTemplate().getPropertyUid());
    }
}
